<template>
	<view class="wap">
		<navbar :parameter='parameter'></navbar>
		<view class="list" v-if="news_list.length > 0">
			<block v-for="(item,index) in news_list " :key="index">
				<navigator class="list-item" :url="'/pages/user/news/details?id='+item.id">
					<view class="acea-row row-between-wrapper">
						<view class="title">{{item.title}}</view>
						<!-- 	<view class="delete" @click.stop="show = true">
							<u-icon name="close" size="24rpx" color="#B4B4B4"></u-icon>
						</view> -->
					</view>
					<view class="cont line1">{{item.content}}</view>
					<view class="time">{{item.createtime}}</view>
				</navigator>
			</block>

		</view>
		<u-empty mode="message" icon="http://cdn.uviewui.com/uview/empty/message.png" text="暂无动态" v-else></u-empty>

		<u-modal :show="show" showCancelButton="true" @confirm="confirm" @cancel="show = false" width="400rpx">
			<view class="slot-content" style="text-align: center;">
				确认删除词条动态？
			</view>
		</u-modal>
		<u-loadmore :status="status" line dashed @loadmore="loadmore" v-if="news_list.length > 0" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				parameter: {
					'navbar': '1',
					'return': '1',
					'title': '平台动态',
					'color': true,
					'class': 'on'
				},
				news_list: [],
				show: false,
				content: '？',
				status: 'loadmore',
				limit: 10,
				page: 1,
				total_num: '',
			};
		},
		onLoad() {
			this.list(1);
		},
		onShow() {

		},
		/**
		 * 用户点击右上角分享
		 */
		onShareAppMessage: function() {
		
		},
		onShareTimeline(res) { //分享到朋友圈
		
		},
		onReachBottom() {
			this.loadmore()
		},
		methods: {
			confirm() {
				this.show = false;
			},
			async list(page) {
				const res = await this.$myRequest({
					url: '/api/notice/lists',
					data: {
						openid: uni.getStorageSync('openid'),
						page: page,
						limit: this.limit
					}
				})
				this.news_list = [...this.news_list, ...res.data.data];
				this.total_num = res.data.total_num;
			},
			loadmore() {
				console.log(11111)
				if (this.total_num == this.news_list.length) {
					this.status = 'nomore';
				} else {
					this.status = 'loading';
					this.page++;
					this.list(this.page);
				}
				setTimeout(() => {
					if (this.total_num == this.news_list.length) this.status = 'nomore';
					else this.status = 'loading';
				}, 2000)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wap {
		padding: 30rpx;
	}

	.list {
		padding: 0 30rpx;
		background-color: #fff;
		border-radius: 12rpx;
	}

	.list-item {
		padding: 30rpx 0;
		background-color: #fff;
		border-bottom: 1px solid #D9D9DA;
	}

	.list-item:last-of-type {
		border-bottom: none;
	}

	.list-item .title {
		font-size: 28rpx;
		font-weight: 700;
		color: #000;
		margin-bottom: 10rpx;
	}

	.list-item .cont {
		font-size: 24rpx;
		color: #999999;
		line-height: 1.8;
		margin-bottom: 10rpx;
	}

	.list-item .time {
		font-size: 24rpx;
		color: #999999;
	}
</style>
